package com.yili.oa.dao;

import com.yili.oa.models.FtAccountDetails;
import com.yili.oa.models.FtAccountDetailsExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface FtAccountDetailsMapper {
    @SelectProvider(type=FtAccountDetailsSqlProvider.class, method="countByExample")
    long countByExample(FtAccountDetailsExample example);

    @DeleteProvider(type=FtAccountDetailsSqlProvider.class, method="deleteByExample")
    int deleteByExample(FtAccountDetailsExample example);

    @Delete({
        "delete from ft_account_details",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into ft_account_details (trade_time, expense, ",
        "income, account_balance, ",
        "trade_type, user_id)",
        "values (#{tradeTime,jdbcType=BIGINT}, #{expense,jdbcType=DECIMAL}, ",
        "#{income,jdbcType=DECIMAL}, #{accountBalance,jdbcType=DECIMAL}, ",
        "#{tradeType,jdbcType=INTEGER}, #{userId,jdbcType=BIGINT})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(FtAccountDetails record);

    @InsertProvider(type=FtAccountDetailsSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(FtAccountDetails record);

    @SelectProvider(type=FtAccountDetailsSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="trade_time", property="tradeTime", jdbcType=JdbcType.BIGINT),
        @Result(column="expense", property="expense", jdbcType=JdbcType.DECIMAL),
        @Result(column="income", property="income", jdbcType=JdbcType.DECIMAL),
        @Result(column="account_balance", property="accountBalance", jdbcType=JdbcType.DECIMAL),
        @Result(column="trade_type", property="tradeType", jdbcType=JdbcType.INTEGER),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT)
    })
    List<FtAccountDetails> selectByExample(FtAccountDetailsExample example);

    @Select({
        "select",
        "id, trade_time, expense, income, account_balance, trade_type, user_id",
        "from ft_account_details",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="trade_time", property="tradeTime", jdbcType=JdbcType.BIGINT),
        @Result(column="expense", property="expense", jdbcType=JdbcType.DECIMAL),
        @Result(column="income", property="income", jdbcType=JdbcType.DECIMAL),
        @Result(column="account_balance", property="accountBalance", jdbcType=JdbcType.DECIMAL),
        @Result(column="trade_type", property="tradeType", jdbcType=JdbcType.INTEGER),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT)
    })
    FtAccountDetails selectByPrimaryKey(Long id);

    @UpdateProvider(type=FtAccountDetailsSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") FtAccountDetails record, @Param("example") FtAccountDetailsExample example);

    @UpdateProvider(type=FtAccountDetailsSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") FtAccountDetails record, @Param("example") FtAccountDetailsExample example);

    @UpdateProvider(type=FtAccountDetailsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(FtAccountDetails record);

    @Update({
        "update ft_account_details",
        "set trade_time = #{tradeTime,jdbcType=BIGINT},",
          "expense = #{expense,jdbcType=DECIMAL},",
          "income = #{income,jdbcType=DECIMAL},",
          "account_balance = #{accountBalance,jdbcType=DECIMAL},",
          "trade_type = #{tradeType,jdbcType=INTEGER},",
          "user_id = #{userId,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(FtAccountDetails record);
}